package com.zr.action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class Login
 */
@WebServlet("/adminlogin")
public class adminLogin extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String uid=request.getParameter("username");
		String pwd=request.getParameter("password");
		if(uid!=null&&uid.equals("admin")&&pwd!=null&&pwd.equals("admin")) {
			HttpSession session=request.getSession();
			session.setAttribute("uid", uid);
			session.setAttribute("pwd", pwd);
			session.setMaxInactiveInterval(1200);
			response.sendRedirect("admin.html");
		}else {
			response.sendRedirect("index.html");
		}
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
